﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using QuanLyGiaoVuDAL.DTO;
using QuanLyGiaoVuUI.Models.SinhVien;
using QuanLyGiaoVuUI.Models.BanTinSinhVien;
using QuanLyGiaoVuUI.Models.RssFeeds;
using QuanLyGiaoVuService.CommandServices;
using QuanLyGiaoVuService.ReportServices;
using QuanLyGiaoVuUI.Models.NguoiDung;
using QuanLyGiaoVuService.CommonServices;
using System.Runtime.CompilerServices;

namespace QuanLyGiaoVuUI.Controllers
{
    public class BanTinSinhVienController : Controller
    {
        private IBanTinCommandService _banTinCommandService;
        private IBanTinReportService _banTinReportService;
        public BanTinSinhVienController(IBanTinCommandService banTinCommandService,
            IBanTinReportService banTinReportService)
        {
            _banTinCommandService=banTinCommandService;
            _banTinReportService=banTinReportService;
        }
        //
        // GET: /BanTinSinhVien/
        
        public ActionResult Index()
        {            
            return View();
        }
        public ActionResult ChiTiet(Guid id)
        {
            BanTinDTO bantin = new BanTinDTO();
            bantin = _banTinReportService.GetBanTinById(id);
            BanTinSinhVienViewModel bantinsv = new BanTinSinhVienViewModel();
            if (bantin != null)
            {
                bantinsv = BanTinSinhVienViewModel.FromBanTinDTO(bantin);
            }
            return View(bantinsv);
        }
        public ActionResult BanTinColumn()
        {
            List<BanTinDTO> bantin = new List<BanTinDTO>();
            bantin = _banTinReportService.GetTopNumbersBanTin(10, 2).ToList(); //2 ban tin cho sinh vien, 1: ban tin cho giang vien
            IEnumerable<BanTinSinhVienViewModel> banTinSinhVienViewModel = BanTinSinhVienViewModel.FromBanTinDTOList(bantin);
            return View(banTinSinhVienViewModel);
        }
        public ActionResult Rss4RumReader()
        {
            RssReader rssReader = new RssReader("http://forum.uit.edu.vn/external.php?type=RSS2");

            return View((rssReader.GetRssFeed() == null) ? rssReader.GetRssFeed() : rssReader.GetRssFeed().Take(7));
        }
        public ActionResult RssDaaUitReader()
        {
            RssReader rssReader = new RssReader("http://daa.uit.edu.vn/rss.xml");

            return View((rssReader.GetRssFeed() == null) ? rssReader.GetRssFeed() : rssReader.GetRssFeed().Take(3));
        }
        public ActionResult ChuongTrinh()
        {
            return View();
        }
        public ActionResult TuyenSinh()
        {
            return View();
        }
    }
}
